Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class com.pacist.diamonds.SuperGridLayout

java.lang.Object
  |
  +--com.pacist.diamonds.SuperGridLayout

public class SuperGridLayout
extends java.lang.Object
implements java.awt.LayoutManager, java.io.Serializable
A more flexible Grid layout. Each row sizes to the highest component in it. Each column sizes to the widest component in it. Extra space is shared out between the rows and columns according to weighting factors.

See Also:
Serialized Form

Field Summary
int alignment
          Alignment of components.
int cols
          Number of columns.
int[] colWeights
          Weights of all columns.
int[] colWidths
          Widths of all columns.
int fill
          Fill of components.
int hGap
          Horizontal gap between components.
int hMargin
          Horizontal margin between components.
int[] rowHeights
          Heights of all rows.
int rows
          Number of rows.
int[] rowWeights
          Weights of all rows.
int vGap
          Vertical gap between components.
int vMargin
          Vertical margin between components.
 
Constructor Summary
SuperGridLayout()
          Creates and initializes a new SuperGridLayout object, with 1 column and a horizontal and vertical gap of 2.
SuperGridLayout(int rows, int cols)
          Creates and initializes a new SuperGridLayout object with the specified number of rows and columns, and vertical and horizontal gaps of 2.
SuperGridLayout(int rows, int cols, int hGap, int vGap)
          Creates and initializes a new SuperGridLayout object with the specified number of rows and columns, and horizontal and vertical gaps.
SuperGridLayout(int rows, int cols, int hGap, int vGap, int hMargin, int vMargin)
          Creates and initializes a new SuperGridLayout object with the specified number of rows and columns, horizontal and vertical gaps, and horizontal and vertical margins.
 
Method Summary
void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Adds the specified named component to the layout.
void calcCellSizes(java.awt.Container target)
          Calculates the sizes of each of the cells in the specified Container.
int getAlignment()
          Returns the current alignment for the components.
int getColumns()
          Returns the current number of columns.
int getColWeight(int col)
          Returns the weight of a given column.
int getFill()
          Returns the current fill for the components.
int getRows()
          Returns the current number of rows.
int getRowWeight(int row)
          Returns the weight of a given row.
void layoutContainer(java.awt.Container target)
          Lays out the specified container.
java.awt.Dimension minimumLayoutSize(java.awt.Container target)
          Returns the minimum dimensions needed to layout the components contained in the specified target container.
java.awt.Dimension preferredLayoutSize(java.awt.Container target)
          Returns the preferred dimensions for this layout given the components in the specified target container.
void removeLayoutComponent(java.awt.Component comp)
          Removes the specified component from the layout.
void setAlignment(int a)
          Sets the alignment of the components.
void setColumns(int cols)
          Sets the number of columns.
void setColWeight(int col, int weight)
          Sets the weight of a specific column.
void setFill(int f)
          Sets the fill of the components.
void setRows(int rows)
          Sets the number of rows.
void setRowWeight(int row, int weight)
          Sets the weight of a specific row.
int sumArray(int[] array, int spacing, int size)
          Returns the total size of an array of heights/widths taking account of spacing and size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

hGap

protected int hGap
Horizontal gap between components.

vGap

protected int vGap
Vertical gap between components.

hMargin

protected int hMargin
Horizontal margin between components.

vMargin

protected int vMargin
Vertical margin between components.

rows

protected int rows
Number of rows.

cols

protected int cols
Number of columns.

rowHeights

protected int[] rowHeights
Heights of all rows.

colWidths

protected int[] colWidths
Widths of all columns.

rowWeights

protected int[] rowWeights
Weights of all rows.

colWeights

protected int[] colWeights
Weights of all columns.

alignment

protected int alignment
Alignment of components.
See Also:
Alignment

fill

protected int fill
Fill of components.
See Also:
Alignment
Constructor Detail

SuperGridLayout

public SuperGridLayout()
Creates and initializes a new SuperGridLayout object, with 1 column and a horizontal and vertical gap of 2.

SuperGridLayout

public SuperGridLayout(int rows,
                       int cols)
Creates and initializes a new SuperGridLayout object with the specified number of rows and columns, and vertical and horizontal gaps of 2.

SuperGridLayout

public SuperGridLayout(int rows,
                       int cols,
                       int hGap,
                       int vGap)
Creates and initializes a new SuperGridLayout object with the specified number of rows and columns, and horizontal and vertical gaps.

SuperGridLayout

public SuperGridLayout(int rows,
                       int cols,
                       int hGap,
                       int vGap,
                       int hMargin,
                       int vMargin)
Creates and initializes a new SuperGridLayout object with the specified number of rows and columns, horizontal and vertical gaps, and horizontal and vertical margins.
Method Detail

setColumns

public void setColumns(int cols)
Sets the number of columns.
Parameters:
cols - the number of columns.

setRows

public void setRows(int rows)
Sets the number of rows.
Parameters:
rows - the number of rows.

getRows

public int getRows()
Returns the current number of rows.
Returns:
int - the number of rows.

getColumns

public int getColumns()
Returns the current number of columns.
Returns:
int - the number of columns.

setAlignment

public void setAlignment(int a)
Sets the alignment of the components.
Parameters:
a - the alignment.

getAlignment

public int getAlignment()
Returns the current alignment for the components.
Returns:
int - the current alignment.

setFill

public void setFill(int f)
Sets the fill of the components.
Parameters:
f - the fill.

getFill

public int getFill()
Returns the current fill for the components.
Returns:
int - the current fill.

setRowWeight

public void setRowWeight(int row,
                         int weight)
Sets the weight of a specific row.
Parameters:
row - the row.
weight - the new weight of the row.

setColWeight

public void setColWeight(int col,
                         int weight)
Sets the weight of a specific column.
Parameters:
col - the column.
weight - the new weight of the column.

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Adds the specified named component to the layout.
Specified by:
addLayoutComponent(java.lang.String, java.awt.Component) in interface java.awt.LayoutManager
Parameters:
name - the String name
comp - the component to be added

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Removes the specified component from the layout.
Specified by:
removeLayoutComponent(java.awt.Component) in interface java.awt.LayoutManager
Parameters:
comp - the component to be removed

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container target)
Returns the minimum dimensions needed to layout the components contained in the specified target container.
Specified by:
minimumLayoutSize(java.awt.Container) in interface java.awt.LayoutManager
Parameters:
target - the Container on which to do the layout
See Also:
java.awt.Container, preferredLayoutSize

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container target)
Returns the preferred dimensions for this layout given the components in the specified target container.
Specified by:
preferredLayoutSize(java.awt.Container) in interface java.awt.LayoutManager
Parameters:
target - the component which needs to be laid out
See Also:
java.awt.Container, minimumLayoutSize

layoutContainer

public void layoutContainer(java.awt.Container target)
Lays out the specified container. This method will actually reshape the components in the specified target container in order to satisfy the constraints of the BorderLayout object.
Specified by:
layoutContainer(java.awt.Container) in interface java.awt.LayoutManager
Parameters:
target - the component being laid out
See Also:
java.awt.Container

sumArray

protected int sumArray(int[] array,
                       int spacing,
                       int size)
Returns the total size of an array of heights/widths taking account of spacing and size.
Parameters:
array - the array of heights/widths.
spacing - the margin to be added to each height/width.
size - the number of items in the array to sum.
Returns:
int - the summation of the array.

calcCellSizes

protected void calcCellSizes(java.awt.Container target)
Calculates the sizes of each of the cells in the specified Container.
Parameters:
target - the container.

getRowWeight

protected int getRowWeight(int row)
Returns the weight of a given row.
Parameters:
row - the specified row.
Returns:
int the weight of the row.

getColWeight

protected int getColWeight(int col)
Returns the weight of a given column.
Parameters:
col - the specified column.
Returns:
int the weight of the column.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD